<template>
	<view>
		<view class="xczxcstrtert">
			<view class="">
				<dxnav :kxczxdf="1"></dxnav>
			</view>
			<view class="pt20 pd pm20">
				<view class="display-flex">
					<view class="mr20 fdxcxdfytry" @tap="jcxdd(idx,sd)" :class="indwd==idx?'act':''"
						v-for="(sd,idx) in jmxcdfds">
						{{sd.name}}
					</view>
				</view>
			</view>
		</view>
		<view class="pd pt20 mcxzcsdfrtry">
			<view class="pr" v-for="sd in list" @tap="hf('/pages/index/index?skill_code='+sd.skill_code)">
				<view class="xczxcrtreyxrt cz ov cz">
					<frImage :src="sd.skill_poster" class="w100 h100 cz"></frImage>
				</view>
				<view class="xcxctxdrty vertical-bottom pder pm20 ">

					<view class="" @tap.stop="cxzcsdsf(sd)">
						<image src="../../static/img/shouchang.png" v-if="sd.favorite" class="xcvxcdytyyrtyr"></image>
						<image src="../../static/img/shouchanga.png" v-else class="xcvxcdytyyrtyr"></image>
					</view>
					<view class="w100 sdfdcxzcvxy pder pt20 pm20">
						<view class="dian cf fz28">
							{{sd.skill_name}}
						</view>
						<view class="fz22 cf mt10">
							{{sd.skill_desc}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script lang="ts" setup>
	import { onLoad } from "@dcloudio/uni-app"
	import { ref } from "vue"
	import { hf, dxrequest, callBack } from "@/util/index.js"
	import frImage from "@/components/fr-image/fr-image.vue"
	import dxnav from "@/components/dxnav.vue";
	import { store } from "@/store/index.js"
	import { jxcxzdf,zhsdr } from "@/util/tts.js"
zhsdr()
store.state.tetsdr =""
	const indwd = ref(0)
	const jmxcdfds = ref([{
		"code": "", //技能分类code
		"name": "全部" //技能分类名称
	}])
	const list = ref([])
	const fenleisd = ref([])
	const kxczxdsf = ref([
		{
			cls: ""
		}, {
			cls: ""
		}, {
			cls: ""
		}, {
			cls: ""
		}, {
			cls: ""
		}, {
			cls: ""
		}, {
			cls: ""
		}, {
			cls: ""
		}, {
			cls: ""
		}, {
			cls: ""
		},

	])
	const category_code = ref()


	const querySkillCategory = async () => {
		const { data } = await dxrequest("api/child/skill/querySkillCategory")
		jmxcdfds.value = [
			...jmxcdfds.value,
			...data.category_list
		]
	}

	const initsdr = async () => {
		const { data } = await dxrequest("api/child/skill/querySkillList?size=999",{
			category_code:category_code.value
		})
		list.value = data.skill_list

	}
	const jcxdd =(idx,data)=>{
		indwd.value=idx 
		category_code.value = data.code
		initsdr()
	}
	onLoad(async () => {
		uni.showLoading({
			title: "加载中..."
		})
		await querySkillCategory()
		await initsdr()
		uni.hideLoading()

	})



	const cxzcsdsf = async(data) => {

		await dxrequest("api/child/user/favorite",{
			"favorite_type": "skill", //收藏类型（skill=技能收藏）
			"favorite_code": data.skill_code, //收藏码（当skill=技能收藏时，favorite_code为该技能code）
			"favorite_status": data.favorite?2:1 //收藏状态（1=收藏；2=取消收藏）
		},"post")
		initsdr()
	}
</script>

<style scoped>
	
</style>